package base;

/**
 * @author liweimin
 * @date 2021/5/28 17:16
 * @since
 */
public class InnerClassTest {

    public Integer age = 15;

    //成员内部类
    public class A {
        public Integer age = 12;

        public void say() {
            System.out.println("*********this is inner class A******");


            //局部内部类---->类似于局部变量 不能使用 public/protected/private 关键字去修饰
            class B {

            }
        }
    }


    public static void main(String[] args) {
        InnerClassTest innerClassTest = new InnerClassTest();
        A a = innerClassTest.new A();
        a.say();

        System.out.println(a.age);
        System.out.println(innerClassTest.age);

        TestInterface interfaceTest = new TestInterface() {
            @Override
            public void saySomething() {
                System.out.println("接口的匿名实现类");
            }
        };

        ParentClass parentClass = new ParentClass("lwm") {
            @Override
            void talk() {
                super.talk();
                System.out.println("这是继承父类的匿名实现类");
            }
        };

        interfaceTest.saySomething();
        parentClass.talk();
    }
}

interface TestInterface {
    void saySomething();
}

class ParentClass {
    public String name;

    public ParentClass(String name) {
        this.name = name;
    }

    void talk() {
        System.out.println(name);
    }
}
